var USER = function() 
{
	var o = {};
	
	o.run = function()
	{
		o.usersexcheck();
		o.clickcheck();
	}
	
	o.usersexcheck = function(){
		
		$.get('/Api/UserIfo/check' , {id:id} , function(ret){
			if( ret.status == true){
				var radionum = document.getElementsByName('radio10');
				var sex = ret.data.sex;
				for(var i=0;i<radionum.length;i++){

					if( radionum[i].value == sex){

						radionum[i].checked = true;
				 
					}	
				}
			}
		});
	}
	
	o.clickcheck = function(){
		$('.user-addresslist').each(function(){
			var moren = $(this).find('.hres1').val();
			
			if( moren == 1 ){
				$(this).addClass('defaultAddr');
				$(this).find('.new-option-r').html('默认地址')
			}
		});
	}
	o.userIfoinsert = function()
	{
		//获取性别单选框被选中的内容
		var radionum = document.getElementsByName('radio10');
 
		for(var i=0;i<radionum.length;i++){

			if(radionum[i].checked){

				var sex = radionum[i].value;
		 
			}	
		}
		//获取个人资料的内容
		
		var nickname	= $('#user-name1').val();//昵称
		var name		= $('#user-name2').val();//姓名
		var year		= $('.sel_year').val();//年
		var month		= $('.sel_month').val();//月
		var day			= $('.sel_day').val();//日
		var telephone	= $('#user-phone').val();//电话
		var email		= $('#user-email').val();//邮箱
		
		
		//ajax接口
		$.get('/Api/UserIfo/insert' , {id:id , nickname:nickname ,name:name , sex:sex , year:year
			, month:month , day:day , telephone:telephone , email:email} , function(ret){
			if( ret.status == true)
			{
				alert( ret.data );
				window.location.href=window.location.href;
			}
			else{
				alert( ret.data );
			}
		});
	}
	
	o.useraddress = function()
	{
		//获取地址的详细信息
		var name		= $('#user-name').val();//收货人
		var telephone	= $('#user-phone').val();//手机号码
		var province	= $('#user-province').val();//省
		var city		= $('#user-city').val();//市
		var area		= $('#user-area').val();//区
		var intro		= $('#user-intro').val();//详细地址
		
		//ajax接口
		$.get('/Api/Address/insert', { id:id , name:name , telephone:telephone ,
			 province:province , city:city , area:area , intro:intro} , function(ret){
			if( ret.status == true)
			{
				alert( ret.data );
				window.location.href=window.location.href;
			}
			else{
				alert( ret.data );
			}
		});
	}
	
	o.useredit = function()
	{
		//获取地址的详细信息
		var name		= $('#user-name').val();//收货人
		var telephone	= $('#user-phone').val();//手机号码
		var province	= $('#user-province').val();//省
		var city		= $('#user-city').val();//市
		var area		= $('#user-area').val();//区
		var intro		= $('#user-intro').val();//详细地址
		
		//ajax接口
		$.get('/Api/Address/edit', { id:id , name:name , telephone:telephone ,
			 province:province , city:city , area:area , intro:intro} , function(ret){
			if( ret.status == true)
			{
				alert( ret.data );
				window.location.href=window.location.href;
			}
			else{
				alert( ret.data );
			}
		});
	}
	
	return o;
}();




